<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>添加积分价格单</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="../../../../elementUI/index.css">
  <link rel="stylesheet" href="../../../../css/index.css">
</head>

<body>
  <div id="app" class="minWidth">
    <el-form ref="contract" inline-message="true" :model="form" :rules="rules" style="width: 100%">
      <div class="table_titel">
        <div class="titel">积分价格单</div>
      </div>
      <el-descriptions :column="4" border size="small">
        </el-descriptions-item>
        <el-descriptions-item label="开始时间">
          <el-form-item prop="Start_Date">
            <el-date-picker v-model.trim="form.Start_Date" type="datetime" placeholder="请选择开始时间"
              value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item label="结算时间">
          <el-form-item prop="End_Date">
            <el-date-picker v-model.trim="form.End_Date" type="datetime" placeholder="请选择结算时间"
              value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item label="补货时间默认00:00:00">
          <el-form-item prop="always">
            <el-time-picker v-model="always" arrow-control placeholder="请选择补货时间默认00:00:00"
              value-format="HH:mm:ss"></el-date-picker>
          </el-form-item>
        </el-descriptions-item>
      </el-descriptions>

      <div class="table_titel">
        <div class="titel">积分销售价格单明细</div>
        <div class="operation">
          <el-button type="primary" size="small" @click="add_integral_unitprice_detail">新增</el-button>
          <el-button type="danger" size="small" @click="remove_integral_unitprice_detail">删除</el-button>
        </div>
      </div>
      <el-descriptions :column="2" border size="small"
        v-for="(item,index) in form.Children.integral_unitprice_detail" :key="index">
        <el-descriptions-item>
          <template slot="label">
            <span>有/无货货主</span>
            <!-- <el-tooltip class="item" effect="dark" content="有/无货货主" placement="top">
              <i class="el-icon-question" style="color:#2c68ff;" />
            </el-tooltip> -->
          </template>
          <el-form-item>
            <el-radio-group @change="ChangeRadio($event, index)" v-model="item.Sign">
              <el-radio label="无货货主" value="0"></el-radio>
              <el-radio label="有货货主" value="1"></el-radio>
            </el-radio-group>
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item v-if="item.Sign=='无货货主'" label="商品编号">
          <el-form-item>
            <el-select v-model.trim="item.Article_SerialNumber" placeholder="请选择商品" filterable style="width: 100%"
              @change="Change_Unit_Price(index,item.Sign)">
              <el-option v-for="(item1,index1) in shop.filter(i=>i.Sign=='1')" :key="index1" :label="item1.Article_Name"
                :value="item1.Article_SerialNumber"></el-option>
            </el-select>
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item v-if="item.Sign=='有货货主'" label="商品编号">
          <el-form-item>
            <el-select v-model.trim="item.Article_SerialNumber" placeholder="请选择商品" filterable
              @change="Change_Unit_Price(index,item.Sign)" style="width: 100%">
              <el-option v-for="(ite,index) in shop.filter(i=>i.Sign=='2')" :key="index" :label="ite.Article_Name"
                :value="ite.Article_SerialNumber"></el-option>
            </el-select>
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item label="商品规格">
          <el-form-item>
            <el-select :disabled="isDisabled||item.specs==0" v-model.trim="item.Article_Specifications_SerialNumber"
              placeholder="请选择规格" filterable style="width: 100%" @change="Change_Specifications_Name(index)">
              <el-option v-for="(item,index) in item.specs" :key="item.Article_Specifications_SerialNumber"
                :label="item.Specifications_Name" :value="item.Article_Specifications_SerialNumber"></el-option>
            </el-select>
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item label="分配数量">
          <el-form-item :rules="Distribute" :prop="'Children.integral_unitprice_detail.' + index + '.Distribute'">
            <el-input v-model.trim="item.Distribute" placeholder="请输入分配数量"></el-input>
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item label="所需积分">
          <el-form-item :rules="Integral_Unit_Price"
            :prop="'Children.integral_unitprice_detail.' + index + '.Integral_Unit_Price'">
            <el-input v-model.trim="item.Integral_Unit_Price" placeholder="请输入所需积分"></el-input>
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item label="所需金额">
          <el-form-item :prop="'Children.integral_unitprice_detail.' + index + '.Unit_Price'">
            <el-input v-model.trim="item.Unit_Price" placeholder="请输入所需金额"></el-input>
          </el-form-item>
        </el-descriptions-item>
        <el-descriptions-item v-if="item.Sign=='有货货主'" label="发货仓库">
          <el-form-item>
            <el-select :disabled="item.Warehouse.length==0" style="width: 100%" v-model="item.isWarehouse" multiple
              placeholder="请选择发货仓库">
              <el-option v-for="(item,index) in item.Warehouse" :key="index"
                :label="item.Warehouse_Name+'(剩余SKU数量:'+item.Remain_Quantity+')'" :value="item.Warehouse_SerialNumber">
                <span>{{item.Warehouse_Name}}(剩余SKU数量:{{item.Remain_Quantity}})</span>
              </el-option>
            </el-select>
          </el-form-item>
        </el-descriptions-item>
      </el-descriptions>
      <div class="table_titel">
        <div class="titel">所属栏目</div>
        <div class="operation">
          <el-button type="primary" size="small" @click="add_integral_unitprice_column">新增</el-button>
          <el-button type="danger" size="small" @click="remove_integral_unitprice_column">删除</el-button>
        </div>
      </div>
      <el-descriptions :column="2" :rules="rules" border size="small"
        v-for="(item,index) in form.Children.integral_unitprice_column" :key="index">
        <el-descriptions-item label="所属栏目">
          <el-form-item prop="Column_Id">
            <el-select v-model.trim="item.ShopColumn_Id" placeholder="请选择栏目" filterable style="width: 100%">
              <el-option v-for="(item,index) in column" :key="index" :label="item.Column_Name"
                :value="item.Column_Id"></el-option>
            </el-select>
          </el-form-item>
        </el-descriptions-item>
      </el-descriptions>
      <div style="margin-bottom: 100px;">
        <div class="table_titel">
          <div class="titel">适用店铺</div>
          <div class="operation">
            <el-button type="primary" size="small" @click="add_integral_scheme_storescope">新增</el-button>
            <el-button type="danger" size="small" @click="remove_integral_scheme_storescope">删除</el-button>
          </div>
        </div>
        <el-descriptions :column="2" border size="small"
          v-for="(item,index) in form.Children.integral_unitprice_storescope" :key="index">
          <el-descriptions-item label="适用店铺">
            <el-form-item :rules="Store_SerialNumber"
              :prop="'Children.integral_unitprice_storescope.' + index + '.Store_SerialNumber'">
              <el-select v-model.trim="item.Store_SerialNumber" placeholder="请选择店铺" filterable style="width: 100%">
                <el-option v-for="(item,index) in store" :key="index" :label="item.Store_Name"
                  :value="item.Store_SerialNumber"></el-option>
              </el-select>
            </el-form-item>
          </el-descriptions-item>
        </el-descriptions>
      </div>
      <el-form-item class="form-operation">
        <el-button @click="window.history.back()">返回</el-button>
        <!-- <el-button type="success" @click="onExcel">导入</el-button> -->
        <el-button type="primary" :loading="loading" @click="submitForm('contract')">提交</el-button>
      </el-form-item>
    </el-form>
    <el-dialog title="导入表格" width="70%" :visible.sync="dialogVisible">
      <el-date-picker v-model.trim="Start_Date" type="datetime" placeholder="请选择开始时间"
        value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
      <el-date-picker v-model.trim="End_Date" type="datetime" placeholder="请选择结束时间"
        value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
      <el-select multiple v-model.trim="Store_SerialNumber" placeholder="请选择店铺" filterable style="width: 50%">
        <el-option v-for="(item,index) in store" :key="index" :label="item.Store_Name"
          :value="item.Store_SerialNumber"></el-option>
      </el-select>
      <el-select v-model.trim="Column_Id" placeholder="商户号" filterable style="width: 100%">
        <el-option v-for="(item,index) in column" :key="index" :label="item.Column_Name"
          :value="item.Column_Id"></el-option>
      </el-select>
      <div style="height: 50px;">
        <el-upload id="Excel" class="upload-demo" action="" :before-remove="beforeRemove" :file-list="fileList"
          :before-upload="uploadDetails">
          <el-button size="small" type="primary" v-show="fileList.length<1">导入</el-button>
          <span slot="tip" class="el-upload__tip" v-show="fileList.length<1">请上传xlsx表格</span>
        </el-upload>
      </div>
      <div style="margin-bottom: 20px;">
        <el-table :data="tableData" id="out-table" stripe border height="calc(60vh - 140px)" style="width: 100%"
          :cell-style="tableCellStyle">
          <el-table-column label="序号" width="50" type="index"></el-table-column>
          <el-table-column prop="Article_SerialNumber" label="商品名称"></el-table-column>
          <el-table-column prop="Article_Specifications_SerialNumber" label="规格"></el-table-column>
          <el-table-column prop="Unit_Price" label="原售价"></el-table-column>
          <el-table-column prop="Integral_Unit_Price" label="现售价">
            <template v-slot="{row}">
              <span :style="row.Integral_Unit_Price>0?'':'color:red'">{{row.Integral_Unit_Price}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="Sign" label="有/无货货主"></el-table-column>
          <el-table-column prop="Distribute" label="上架数量">
            <template v-slot="{row}">
              <span :style="row.Distribute>0?'':'color:red'">{{row.Distribute}}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column label="操作" width="80">
            <template v-slot="{row}">
              <el-button size="small" type="danger" @click="Filter(1,row)">删除</el-button>
            </template>
          </el-table-column> -->
        </el-table>
      </div>
      <div style="display: flex; justify-content: center; width: 100%;">
        <el-button type="danger" @click="Filter(2)">筛掉异常数据</el-button>
        <el-button type="primary" :loading="loading" @click="submitForm1">提交</el-button>
      </div>
    </el-dialog>
  </div>
  <script type="text/javascript" src="../../../../js/jquery-3.6.0.min.js"></script>
  <script type="text/javascript" src="../../../../js/jquery.cookie.js"></script>
  <script type="text/javascript" src="../../../../js/vue.min.js"></script>
  <script type="text/javascript" src="../../../../elementUI/index.js"></script>
  <script type="text/javascript" src="../../../../js/utils.js"></script>
  <script type="text/javascript" src="../../../../js/ID_Validity.js"></script>
  <script type="text/javascript" src="../../../../js/FileSaver.min.js"></script>
  <script type="text/javascript" src="../../../../js/FileSaver.js"></script>
  <script type="text/javascript" src="../../../../js/xlsx.full.min.js"></script>
  <script type="text/javascript" src="./js/Add.js"></script>
</body>

</html>